# ~*~ coding: utf-8 ~*~
from flask_wtf import FlaskForm
from wtforms import StringField
from wtforms.validators import InputRequired

from apps.common.form import ErrorFormMinx

__all__ = ['FunctionForm']


class FunctionForm(ErrorFormMinx, FlaskForm):
    name = StringField(validators=[InputRequired(message="函数名称不能为空")])
    method = StringField(validators=[InputRequired(message="函数对象不能为空")])
    description = StringField()

    @property
    def data(self):
        return {
            'name': self.name.data.strip(),
            'method': self.method.data.strip(),
            'description': self.description.data.strip(),
        }
